<?php
// +---------------------------------------------------------------------+
// | OneBase    | [ WE CAN DO IT JUST THINK ]                            |
// +---------------------------------------------------------------------+
// | Licensed   | http://www.apache.org/licenses/LICENSE-2.0 )           |
// +---------------------------------------------------------------------+
// | Author     | Bigotry <3162875@qq.com>                               |
// +---------------------------------------------------------------------+
// | Repository | https://gitee.com/Bigotry/OneBase                      |
// +---------------------------------------------------------------------+

namespace app\admin\controller;

use app\common\model\ChannelWorkClass;
use app\common\model\ChannelWorkComment;

/**
 * Work控制器
 */
class Work extends AdminBase
{
    
    /**
     * Work列表
     */
    public function WorkList()
    {
        
        $where = $this->logicWork->getWhere($this->param);
//        dump($this->logicWork->getWorkList($this->param,$where, 'a.*,c.username,c.mobile', 'a.create_time desc'));exit;
        $this->assign('list', $this->logicWork->getWorkList($this->param,$where, 'a.*,c.username,c.mobile', 'a.create_time desc'));
        $this->assign('class_list', ChannelWorkClass::all(['status'=>1]));
        $this->assign('param',$this->param);
        return $this->fetch('work_list');
    }
    
    /**
     * Work添加
     */
    public function WorkAdd()
    {
        
        $this->WorkCommon();
        $this->assign('work_class_list', $this->logicWork->getWorkCategoryList([], 'id,classname', '', false));
        return $this->fetch('work_edit');
    }
    
    /**
     * Work编辑
     */
    public function WorkEdit()
    {
        
        $this->WorkCommon();

        $info = $this->logicWork->getWorkInfo(['a.id' => $this->param['id']], 'a.*');

        $this->assign('info', $info);
        $this->assign('comment', ChannelWorkComment::all(['wid'=>$this->param['id']]));
        return $this->fetch('work_edit');
    }
    
    /**
     * Work添加与编辑通用方法
     */
    public function WorkCommon()
    {
        
        IS_POST && $this->jump($this->logicWork->WorkEdit($_POST));
        

    }
    

   /**
     * 数据状态设置
     */
    public function excel()
    {

        IS_POST && $this->jump($this->logicWork->excel( $this->param));
        return $this->fetch('excel');
    }
    

    /**
     * 数据状态设置
     */
    public function setStatus()
    {
        
        $this->jump($this->logicAdminBase->setStatus('ChannelWorkContent', $this->param));
    }


    /**
     * 游戏分类添加
     */
    public function WorkCategoryAdd()
    {

        IS_POST && $this->jump($this->logicWork->WorkCategoryEdit($this->param));


        return $this->fetch('work_class_edit');
    }

    /**
     * 游戏分类编辑
     */
    public function WorkCategoryEdit()
    {

        IS_POST && $this->jump($this->logicWork->WorkCategoryEdit($this->param));

        $info = $this->logicWork->getWorkCategoryInfo(['id' => $this->param['id']]);

        $this->assign('info', $info);

        return $this->fetch('work_class_edit');
    }

    /**
     * 游戏分类列表
     */
    public function WorkCategoryList()
    {

        $this->assign('list', $this->logicWork->getWorkCategoryList());

        return $this->fetch('work_class_list');
    }

    /**
     * 游戏分类删除
     */
    public function WorkCategoryDel($id = 0)
    {

        $this->jump($this->logicWork->WorkCategoryDel(['id' => $id]));
    }

    /**
     * 数据状态设置
     */
    public function update_info()
    {

        $this->jump($this->logicWork->update_info( $this->param));
    }
}
